var _class, _temp;

import Taro from '@tarojs/taro-rn';
import * as tslib_1 from "tslib";
import React from 'react';
import { Component } from "@tarojs/taro-rn";
import { View, Image } from "@tarojs/components-rn";
import { inject, observer } from "@tarojs/mobx-rn";
import { getRuntime } from "../../utils/common";
import my_profitStyleSheet from "./my_profit_styles";

import right_blue from "../../assets/img/right_blue.png";
import bg_17 from "../../assets/img/bg_17.jpg";
var _styleSheet = my_profitStyleSheet;
let MyProfit = (_temp = _class = class MyProfit extends Component {
  constructor(props) {
    super(props);
    this.state = {
      log: {},
      userInfo: getRuntime().getUserInfo()
    };
  }
  componentWillMount() {
    Taro.setNavigationBarTitle({ title: '我的收益' });
    this.getUserBenifitsStatistics();
  }
  handelRouter(url = '/pages/index/index') {
    getRuntime().navigateTo(url);
  }
  nowCash() {
    if (this.state.userInfo.commision <= 0) {
      getRuntime().showToast('余额不足~');
      return;
    }
    getRuntime().navigateTo('/pages/user/cash_now');
  }
  getUserBenifitsStatistics() {
    let { userStore } = this.props.stores;
    userStore.getUserBenifitsStatistics({
      callback: res => {
        this.setState({ log: res });
      }
    });
  }
  render() {
    let { userInfo, log } = this.state;
    return <View style={_styleSheet["my-my_profit_index"]}>
        <Image src={bg_17} style={_styleSheet["my-bg"]} />

        <View style={_styleSheet["info"]}>
          <View style={_styleSheet["list-info"]}>当前收益(元)</View>
          <View style={_styleSheet["money"]}>{userInfo.commision}</View>
          <View onClick={this.nowCash.bind(this)} style={_styleSheet["btn-cash"]}>立即提现</View>
        </View>

        <View style={_styleSheet["my-from"]}>
          <View style={_styleSheet["item-group"]}>
            <View style={_styleSheet["line"]}>
              <View style={_styleSheet["list-title"]}>今日收益</View>
              <View style={[_styleSheet["list-desc"], _styleSheet["list-desc-active"]]}>{log.todayBenifits}</View>
            </View>

            <View style={_styleSheet["line"]}>
              <View style={_styleSheet["list-title"]}>昨日收益</View>
              <View style={_styleSheet["list-desc"]}>{log.yesterdayBenifits}</View>
            </View>

            <View style={_styleSheet["line"]}>
              <View style={_styleSheet["list-title"]}>累计收益</View>
              <View style={_styleSheet["list-desc"]}>{userInfo.commision}</View>
            </View>
          </View>
        </View>

        <View onClick={this.handelRouter.bind(this, '/pages/user/my_profit_list')} style={_styleSheet["btn-show"]}>
          <View>查看明细</View>
          <Image src={right_blue} style={_styleSheet["icon-drop-down"]} />
        </View>

      </View>;
  }
}, _class.config = {
  navigationBarTitleText: '我的收益'
}, _temp);
MyProfit = tslib_1.__decorate([inject("stores"), observer], MyProfit);
export default MyProfit;